<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript" src="jquery.js"></script>

<script type="text/javascript">
$(function() {

$(".vote").click(function() 
{

var id = $(this).attr("id");
var name = $(this).attr("name");
var dataString = 'id='+ id ;
var parent = $(this);


if(name=='up')
{

$(this).fadeIn(200).html('');
$.ajax({
   type: "POST",
   url: "up.php",
   data: dataString,
   cache: false,

   success: function(html)
   {
    parent.html(html);
  
  }  });
  
}
else
{

$(this).fadeIn(200).html('');
$.ajax({
   type: "POST",
   url: "down.php",
   data: dataString,
   cache: false,

   success: function(html)
   {
       parent.html(html);
  }
   
 });


}
  
  
   

	});

});
</script>
<style type="text/css">
#main{
height:auto;
margin:0 auto;
width:500px;
margin-bottom: 10px;
}
.clearfix{
clear:both;
}
#left{
float:left;
width:40px;
height:auto;
text-align:center;
}
#message{
float:right;
width:460px;
height:auto;
margin-top: 14px;
font-family:Arial, Helvetica, sans-serif;
font-size:12px;
font-weight:bold;
}
.up{
background-image:url(up.png);
}
</style>
</head>

<body>
<?php
include('config.php');
$sql=mysql_query("SELECT * FROM messages");
while($row=mysql_fetch_array($sql))
{
$message=$row['msg'];
$mes_id=$row['mes_id'];
$totalvotes=$row['totalvotes'];
?>
<div id="main">
	<div id="left">
	<span class='up'><a href="" class="vote" id="<?php echo $mes_id; ?>" name="up"><img src="up.png" alt="Down" /></a></span><br />
	<?php echo $totalvotes ?><br />
	<span class='down'><a href="" class="vote" id="<?php echo $mes_id; ?>" name="down"><img src="down.png" alt="Down" /></a></span>
	</div>
	<div id="message">
		<?php echo $message ?>
	</div>
	<div class="clearfix"></div>
</div>
<?php } ?>
</body>
</html>
